package com.ruoyi.finance.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.finance.domain.CommissionExtend;
import com.ruoyi.finance.service.ICommissionExtendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * CommissionController
 * 提成信息接口管理
 *
 * @author Elon
 */
@RestController
@RequestMapping("/commission")
public class CommissionController extends BaseController {
    @Autowired
    private ICommissionExtendService commissionExtendService;

    //@GetMapping("/list")
    //@SaCheckPermission("'finance:commissionData:list")
    //public TableDataInfo list(CommissionQueryParams params) {
    //    List<CommissionRecord> list = commissionSalesDataService.getSalesCommissionRecord(params);
    //    return TableDataInfo.build(list);
    //}
    //
    //@GetMapping("/export")
    //@SaCheckPermission("'finance:commissionData:export")
    //public AjaxResult export(CommissionQueryParams params) {
    //    List<CommissionRecord> list = commissionSalesDataService.getSalesCommissionRecord(params);
    //    if (params.getType() == 0) {
    //        ExcelUtil<CommissionRecord> util = new ExcelUtil<>(CommissionRecord.class);
    //        return util.exportExcel(list, "提成数据");
    //    } else {
    //        ExcelUtil<CommissionRecordVo> util = new ExcelUtil<>(CommissionRecordVo.class);
    //        List<CommissionRecordVo> voList = new ArrayList<>();
    //        list.forEach(item -> {
    //            CommissionRecordVo commissionRecordVo = new CommissionRecordVo();
    //            BeanUtils.copyProperties(item, commissionRecordVo);
    //            voList.add(commissionRecordVo);
    //        });
    //        return util.exportExcel(voList, "提成数据");
    //    }
    //}

    @PostMapping
    @SaCheckPermission("'finance:commissionData:update")
    public R save(@RequestBody CommissionExtend commissionExtend) {
        if (commissionExtend.getId() != null) {
            return toAjaxR(commissionExtendService.updateCommissionExtend(commissionExtend));
        } else {
            return toAjaxR(commissionExtendService.insertCommissionExtend(commissionExtend));
        }
    }


}


